package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.dto.OrdersRejectionDTO;
import com.sky.entity.OrderDetail;
import com.sky.entity.Orders;
import com.sky.entity.StatusCount;
import com.sky.vo.OrderStatisticsVO;
import com.sky.vo.OrderVO;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface OrdersMapper {

    /**
     * 插入订单数据
     * @param orders
     */
    void submit(Orders orders);

    /**
     * 根据订单号和用户id查询订单
     * @param orderNumber
     * @param userId
     */
    @Select("select * from orders where number = #{orderNumber} and user_id= #{userId}")
    Orders getByNumberAndUserId(String orderNumber, Long userId);

    /**
     * 修改订单信息
     * @param orders
     */
    void update(Orders orders);


    /**
     * 查询历史订单
     * @param queryDTO
     * @return
     */
    Page<OrderVO> searchHistoryOrders(OrdersPageQueryDTO queryDTO);


    /**
     * 根据订单id查询订单
     * @param id
     * @return
     */
    OrderVO searchOrderById(Long id);

    /**
     * 条件查询订单
     * @param ordersPageQueryDTO
     * @return
     */
    Page<OrderVO> pageQuery(OrdersPageQueryDTO ordersPageQueryDTO);


    /**
     * 订单状态统计
     * @return
     */
    Integer statistics(Integer status);

    void rejectById(Orders orders);


    List<Orders> searchStatusBy(Integer pendingPayment, LocalDateTime localDateTime);

}
